package myJs.admin

import myJs.Implicits._
import myJs.admin.companyMemeberManage.CompanyMemberManage
import myJs.admin.memberManage.{Cp, MemberManage}
import myJs.admin.specialMemberManage.SpecialMemberManage
import myJs.admin.wechatMemberManage.WechatMemberManage
import myJs.assets
import myJs.assets._
import myJs.cps.{PureInputCp, Style, TextAlign}
import myJs.myPkg.{HashRouter, MyFetch, NProgress, NavigateOptions, Outlet, ReactRouterDOM, Route, Routes}
import myJs.tool.Tool
import org.scalajs.dom.document
import org.scalajs.dom.window.localStorage
import slinky.core.FunctionalComponent
import slinky.core.annotations.react
import slinky.core.facade.Hooks._
import slinky.web.html._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.scalajs.js
import scala.scalajs.js.JSON
import scala.scalajs.js.Dynamic.{global => g}

/**
 * Created by yz on 22/4/2022
 */
@react object AdminCp {

  type Props = Unit

  private val css = List(
    assets.LayerCss,
    assets.SweetalertCss,
    assets.BootstrapDatepicker3Css,
    assets.BootstrapMinCss,
    assets.BootstrapThemeMinCss,
    assets.FontAwesomeMinCss,
    assets.LayoutCss,
    assets.ComponentsCss,
    assets.Light2Css,
    assets.UniformDefaultCss,
    assets.BootstrapTableCss,
    assets.NprogressCss,
    assets.TableFilterCss,
    assets.MyCss,
  )

  val pages = List(MemberManage, CompanyMemberManage,SpecialMemberManage,WechatMemberManage)

  val component = FunctionalComponent[Props] { props =>

    val navigate = ReactRouterDOM.useNavigate()

    object FTool {

    }

    useEffect(() => {
      LayoutJs.init()
    }, List()
    )

    useEffect(() => {
      val role = localStorage.getItem("role")
      if (role != "admin") {
        navigate("/",options = NavigateOptions(state = js.Dictionary("message"->"请先登录！")))
      }
    }
    )


    div(
      div(className := "page-content-wrapper",
        div(className := "page-header-fixed page-quick-sidebar-over-content",
          LeftCp(),
          div(className := "page-container",
            HeaderCp(),
            TagCp(),
            Outlet()
          )
        )
      )
    )


  }

}
